<template>
  <div>
    <!-- table -->
    <!-- 改善信息反馈查询 - 明细 -->
    <BreakSpace label="归档信息" :containerStyle="{ marginBottom: '10px' }"/>
    <FormPanel ref="formPanel1" :list="formList" :cols="3" :formType="'add'" labelWidth="100" :isSubmitBtn="false"
               @formChange="formChangeHandle"/>
    <div style="margin-bottom: 1rem;"></div>
    <BreakSpace label="故障码列表" :containerStyle="{ marginBottom: '10px' }"/>
    <FilterTable
      ref="table"
      :columns="columns"
      :params="fetchParams"
      :dataSource="dataList"
      :datakey="'items'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      selectionType="single"
    ></FilterTable>
    <div style="margin-bottom: 1rem;"></div>
    <BreakSpace label="主损件列表" :containerStyle="{ marginBottom: '10px' }"/>
    <FilterTable
      ref="table"
      :columns="columns2"
      :params="fetchParams"
      :dataSource="dataList2"
      :datakey="'items'"
      :onColumnsChange="columns => (this.columns2 = columns2)"
      :onRowSelectChange="selectChange"
      selectionType="single"
    ></FilterTable>
    <div style="margin-bottom: 1rem;"></div>
    <BreakSpace label="质量部回复信息" :containerStyle="{ marginBottom: '10px' }"/>
    <FormPanel ref="formPanel1" :list="formList2" :cols="3" :formType="'add'" labelWidth="100" :isSubmitBtn="false"
               @formChange="formChangeHandle"/>
    <div style="margin-bottom: 1rem;"></div>
    <BreakSpace label="质量报告列表" :containerStyle="{ marginBottom: '10px' }"/>
    <FilterTable
      ref="table"
      :columns="columns3"
      :params="fetchParams"
      :dataSource="dataList3"
      :datakey="'items'"
      :onColumnsChange="columns => (this.columns3 = columns3)"
      :onRowSelectChange="selectChange"
      selectionType="single"
    >
      <template slot="controls" slot-scope="props">
        <multiuse-button size="small" type="primary" icon="el-icon-plus" @click="">下载</multiuse-button>
      </template>
    </FilterTable>
    <div style="margin-bottom: 1rem;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
    </div>
    <BaseDialog :visible.sync="visible" :title="'质量信息'" destroyOnClose width="850px" :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}">
      <DetailInDetailForm @close="close"></DetailInDetailForm>
    </BaseDialog>
    <div style="margin-bottom: 4rem;"></div>
  </div>
</template>
<script>
// import res from '@/mock/tableData';
import DetailInDetailForm from './DetailInDetailForm.vue';

export default {
  // mixins: [dictionary],
  components: {
    DetailInDetailForm
  },
  data() {
    return {
      dataList: [],
      dataList2: [],
      dataList3: [],
      collapse: false,
      visible: false,
      infoId: null,
      columns: this.creatHeader(),
      columns2: this.creatHeader2(),
      columns3: this.creatHeader3(),
      // topFilterInit: this.topFilterInitFun(),
      // fetchApi: getUser,
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      formList: this.createFormList(),
      formList2: this.createFormList2(),
      saveData: null
    };
  },
  created() {
    // this.dataList = [...res.data.items];
    this.dataList2 = [...res.data.items];
    this.dataList3 = [...res.data.items];
    this.dataList4 = [...res.data.items];
    console.log(this.dataList);
  },
  methods: {
    //基本信息
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '案例编号',
          fieldName: 'techStatus',
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '案例主题',
          fieldName: 'ifFirst',
          selfCols: 2,// 元素占据几行
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '车型名称',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'SELECT',
          label: '故障等级',
          fieldName: 'claimType',
          placeholder: '请选择',
          initialValue: '',
          itemList: [{ text: '保存', value: '1001' }],
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '案例创建日期',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '故障现象代码',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '故障现象描述',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '故障次数',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '系统代码',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '系统名称',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '子系统代码',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '子系统名称',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '现象代码',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        }, {
          type: 'INPUT',
          label: '现象描述',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '邮寄说明',
          fieldName: 'dcPerson',
          readonly: true,// 只读
          disabled: true, // 置会
          selfCols: 3,// 元素占据几行
          rows: 1
        },
        {
          type: 'TEXT_AREA',
          label: '案例描述',
          fieldName: 'evaluateRemarks',
          readonly: true,// 只读
          disabled: true,// 置会
          selfCols: 3,// 元素占据几行
          rows: 2
        },
        {
          type: 'TEXT_AREA',
          label: '建议',
          fieldName: 'evaluateRemarks',
          readonly: true,// 只读
          disabled: true,// 置会
          selfCols: 3,// 元素占据几行
          rows: 2
        },
        {
          type: 'INPUT',
          label: '附件',
          fieldName: 'title',
          placeholder: '请输入附件...',
          selfCols: 3,
          readonly: true, // 只读
          unitRender: props => {
            return (
              <div>
                <multiuse-button type="primary" style="background-color: #1890FF;color: #FFFFFF">
                  下载文件
                </multiuse-button>
              </div>
            );
          }
        }
      ];
    },
    //故障码列表
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '故障码', dataIndex: 'date', sorter: true },
        { title: '故障描述', dataIndex: 'date', sorter: true }

      ];
    },
    //主损件列表
    creatHeader2() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '主损件代码', dataIndex: 'date', sorter: true },
        { title: '主损件名称', dataIndex: 'date', sorter: true }

      ];
    },
    //质量部回复信息
    createFormList2() {
      return [
        {
          type: 'SELECT',
          label: '调查结论',
          fieldName: 'claimType',
          placeholder: '请选择',
          initialValue: '',
          itemList: [{ text: '保存', value: '1001' }],
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '回复日期',
          fieldName: 'techStatus',
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'SELECT',
          label: '故障等级',
          fieldName: 'claimType',
          placeholder: '请选择',
          initialValue: '',
          itemList: [{ text: '保存', value: '1001' }],
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: 'QIR编号',
          fieldName: 'ifFirst',
          selfCols: 3,// 元素占据几行
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: '配件代码',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true, // 置会
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'dealerName',
          readonly: true,// 只读
          disabled: true // 置会
        },
        {
          type: 'INPUT',
          label: '市场处理措施',
          fieldName: 'dcPerson',
          readonly: true,// 只读
          disabled: true, // 置会
          selfCols: 2,// 元素占据几行
          rows: 1
        },
        {
          type: 'TEXT_AREA',
          label: '故障原因',
          fieldName: 'evaluateRemarks',
          readonly: true,// 只读
          disabled: true,// 置会
          selfCols: 3,// 元素占据几行
          rows: 3
        },
        {
          type: 'TEXT_AREA',
          label: '改善措施',
          fieldName: 'evaluateRemarks',
          readonly: true,// 只读
          disabled: true,// 置会
          selfCols: 3,// 元素占据几行
          rows: 2
        }
      ];
    },
    //质量报告列表
    creatHeader3() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          render: props => {
            return (
              <div style="text-align:center">
                <multiuse-button type="text" onClick={() => this.detailTurnOn()}>
                  明细
                </multiuse-button>
              </div>
            );
          }
        },
        { title: '经销商代码', dataIndex: 'wmStatus', sorter: true },
        { title: '经销商名称', dataIndex: 'whName', sorter: true },
        { title: '质量报告单号', dataIndex: 'whName', sorter: true },
        { title: '索赔单号', dataIndex: 'whCode', sorter: true },
        { title: '维修工单号', dataIndex: 'modelName', sorter: true },
        { title: 'VIN', dataIndex: 'modelCode', sorter: true },
        { title: '生产日期', dataIndex: 'createdBy', sorter: true },
        { title: '销售日期', dataIndex: 'createdAt', sorter: true },
        { title: '车型名称', dataIndex: 'updatedBy', sorter: true },
        { title: '主损件代码', dataIndex: 'updatedAt', sorter: true },
        { title: '主损件名称', dataIndex: 'updatedAt', sorter: true },
        { title: '申请时间', dataIndex: 'updatedAt', sorter: true },
        { title: '申请人', dataIndex: 'updatedAt', sorter: true },
        { title: '审核时间', dataIndex: 'updatedAt', sorter: true },
        { title: '审核人', dataIndex: 'updatedAt', sorter: true }
      ];
    },

    formChangeHandle(val) {
      console.log(val);
      this.saveData = val;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    // //取消操作
    // closeDialog() {
    //   this.$emit('close', {visible: false, data: this.selectedRows, type: 'close'});
    // },
    detailTurnOn() {
      this.visible = true;
    },
    close() {
      this.visible = false;
      this.fetchParams = { ...this.fetchParams };
    }
  }
};
</script>

<style lang="less" scoped></style>
